package com.waltercedric.java.joomla.gridupdater.protocol;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import com.waltercedric.java.joomla.gridupdater.vo.Site;

import ch.ethz.ssh2.Connection;
import ch.ethz.ssh2.Session;

public class SSH implements SiteConnector {

	public SSH() {
		super();
	}

	public Session open(Site site) throws IOException {
		Connection connection = new Connection(site.getSiteurl(),
				site.getPort());
		
		connection.connect();

		connection.authenticateWithPublicKey(site.getLogin(),
				new File(site.getPrivateKeyLocation()), site.getPwd());
		
		return connection.openSession();
	}

	public void executeCommand(Session session, String command)
			throws IOException {
		session.execCommand(command);
	}

	@Override
	public void connect() {
		// TODO Auto-generated method stub
	}

  @Override
  public FileInputStream getFile(String file) {
    // TODO Auto-generated method stub
    return null;
  }

  @Override
  public void sendFile(FileInputStream file) {
    // TODO Auto-generated method stub
    
  }

}
